<template>
  <div>
    <div class="comment" v-for="comment in comments" :key="comment.id">
      <div class="comment_left">
        <a href="javascript:;">
          <img :src="comment.user.avatarUrl" alt="" />
        </a>
      </div>
      <div class="comment_right">
        <div class="right_header">
          <div class="meta">
            <div class="user">{{ comment.user.nickname }}</div>
            <div class="time">{{ comment.time | formatDate("Y年m月d日") }}</div>
          </div>
          <div class="like">
            <span>{{ comment.likedCount }}</span>
            <i class="iconfont icon-like"></i>
          </div>
        </div>
        <div class="right_content">
          <span>{{ comment.content }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    comments: {
      type: Array,
      default: () => [],
    },
  },
};
</script>

<style lang="less" scoped>
.comment {
  display: flex;
  padding-top: 10px;
  width: 100%;
  .comment_left {
    margin: 0 10px;
    a {
      img {
        border-radius: 50%;
        width: 30px;
        height: 30px;
      }
    }
  }
  .comment_right {
    flex-grow: 1;
    padding-right: 10px;
    padding-bottom: 11px;
    border-bottom: 1px solid #eee;
    .right_header {
      display: flex;
      justify-content: space-between;
      .meta {
        .user {
          font-size: 14px;
          color: #666;
          line-height: 20px;
        }
        .time {
          font-size: 9px;
          color: #999;
        }
      }
      .like {
        span {
          font-size: 11px;
          color: #999;
        }
        i {
          font-size: 14px;
          margin-left: 6px;
        }
      }
    }
    .right_content {
      font-size: 15px;
      margin-top: 12px;
      line-height: 22px;
      span {
        vertical-align: middle;
      }
    }
  }
}
</style>